<?php
use_helper('I18N');
?>
<div class="breadcrumbs" id="breadcrumbs">
<script type="text/javascript" language="javascript">
    try {
        ace.settings.check('breadcrumbs', 'fixed')
    } catch(e) {
    }
    var datagrid = null;
    $(function() {
        $("#cbo_ecashAmount").change(function(){
            var ecashFinal = parseFloat($("#cbo_ecashAmount").val());

            $("#ecashFinal").autoNumericSet(ecashFinal);
        }).change();

        $("#btnSubmit").click(function(){
            $("#withdrawForm").submit();
        });

        $("#withdrawForm").validate({
            messages : {
                transactionPassword: {
                    remote: "Security Password is not valid."
                }
            },
            rules : {
                "transactionPassword" : {
                    required : true
                    , remote: "/member/verifyTransactionPassword"
                }
            },
            submitHandler: function(form) {
                waiting();
                var ecashBalance = $('#ecashBalance').autoNumericGet();
                var withdrawAmount = parseFloat($("#cbo_ecashAmount").val());

                if (withdrawAmount > parseFloat(ecashBalance)) {
                    error("In-sufficient MG");
                    return false;
                }

                form.submit();
            }
        });
    }); // end function
</script>

    <ul class="breadcrumb">
        <li>
            <i class="icon-home home-icon"></i>
            <a href="#"><?php echo __('Withdrawal') ?></a>
        </li>
        <li class="active"><?php echo __('MG Withdrawal') ?></li>
    </ul>
    <!-- .breadcrumb -->

    <div class="nav-search" id="nav-search">
        <form class="form-search">
            <span class="input-icon">
                <input type="text" placeholder="Search ..." class="nav-search-input"
                       id="nav-search-input" autocomplete="off"/>
                <i class="icon-search nav-search-icon"></i>
            </span>
        </form>
    </div>
    <!-- #nav-search -->
</div>

<div class="page-content">
<!--<div class="page-header">
    <h1>
        <?php /*echo __('Withdrawal') */?>
        <small>
            <i class="icon-double-angle-right"></i>
            <?php /*echo __('MG Withdrawal') */?>
        </small>
    </h1>
</div>-->
<!-- /.page-header -->
<div class="row">
<h3 class="header smaller lighter green"><?php echo __('MG Withdrawal') ?></h3>

<div class="col-xs-12">
<!-- PAGE CONTENT BEGINS -->

<?php include_component('component', 'alert', array('param' => $sf_user->getAttribute(Globals::SESSION_DISTID, 0))) ?>

<div class="row">
<div class="space-6"></div>

<div class="col-xs-12">
    <div class="table-responsive">
        <form action="/member/ecashWithdrawal" id="withdrawForm" name="withdrawForm" method="post" class="form-horizontal" role="form">

            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="ecashBalance"><?php echo __('MG Balance'); ?></label>

                <div class="col-sm-9">
                    <input type="text" name="ecashBalance" id="ecashBalance" disabled="disabled" placeholder="<?php echo __('MG Balance'); ?>" class="col-xs-10 col-sm-5" value="<?php echo number_format($ledgerAccountBalance, 2); ?>"/>
                </div>
            </div>

            <div class="space-4"></div>

            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="cbo_ecashAmount"><?php echo __('MG Withdrawal Amount'); ?></label>

                <div class="col-sm-9">
                    <select name="ecashAmount" id="cbo_ecashAmount">
                        <option value="500">500</option>
                        <option value="600">600</option>
                        <option value="700">700</option>
                        <option value="800">800</option>
                        <option value="900">900</option>
                        <option value="1000">1,000</option>
                        <option value="1100">1,100</option>
                        <option value="1200">1,200</option>
                        <option value="1300">1,300</option>
                        <option value="1400">1,400</option>
                        <option value="1500">1,500</option>
                        <option value="1600">1,600</option>
                        <option value="1700">1,700</option>
                        <option value="1800">1,800</option>
                        <option value="1900">1,900</option>
                        <option value="2000">2,000</option>
                        <option value="2500">2,500</option>
                        <option value="3000">3,000</option>
                        <option value="3500">3,500</option>
                        <option value="4000">4,000</option>
                        <option value="4500">4,500</option>
                        <option value="5000">5,000</option>
                        <?php
                            for ($i = 6000; $i <= 100000; $i = $i + 1000) {
                                echo "<option value='".$i."'>".number_format($i, 0)."</option>";
                            }

                        ?>
                    </select>
                </div>
            </div>

            <div class="space-4"></div>

            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="ecashFinal"><?php echo __('Sub Total (added handling fee)'); ?></label>

                <div class="col-sm-9">
                    <input name="ecashFinal" type="text" id="ecashFinal" readonly="readonly" class="col-xs-10 col-sm-5" />
                </div>
            </div>

            <div class="space-4"></div>

            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="transactionPassword"><?php echo __('Security Password'); ?></label>

                <div class="col-sm-9">
                    <input name="transactionPassword" type="password" id="transactionPassword"
                           placeholder="<?php echo __('Security Password'); ?>" value="" class="col-xs-10 col-sm-5" />
                </div>
            </div>

            <div class="space-4"></div>

            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right"><font color="#dc143c"> <?php echo __('NOTE :') ?></font></label>

                <div class="col-sm-9">
                    <font color="#dc143c"> <?php echo __('1. Minimum withdrawal amount : RMB 100
                        <br>2. Processing time : 5 working days') ?></font>
                </div>
            </div>

            <div class="clearfix form-actions">
                <div class="col-md-offset-3 col-md-9">
                    <button class="btn btn-info" type="button" id="btnSubmit">
                        <i class="icon-ok bigger-110"></i>
                        <?php echo __('Submit') ?>
                    </button>
                </div>
            </div>
        </form>


        <script type="text/javascript" language="javascript">
            var datagrid = null;
            $(function() {
                datagrid = $("#datagrid").r9jasonDataTable({
                    // online1DataTable extra params
                    "idTr" : true, // assign <tr id='xxx'> from 1st columns array(aoColumns);
                    "extraParam" : function(aoData) { // pass extra params to server
                    },
                    "reassignEvent" : function() { // extra function for reassignEvent when JSON is back from server
                        reassignDatagridEventAttr();
                    },

                    // datatables params
                    "bLengthChange": true,
                    "bFilter": false,
                    "bProcessing": true,
                    "bServerSide": true,
                    "bAutoWidth": false,
                    "sAjaxSource": "/finance/ecashWithdrawalList",
                    "sPaginationType": "full_numbers",
                    "aaSorting": [
                        [1,'desc']
                    ],
                    "aoColumns": [
                        { "sName" : "dist_id", "bVisible" : false,  "bSortable": true},
                        { "sName" : "created_on",  "bSortable": true},
                        { "sName" : "deduct",  "bSortable": true},
                        { "sName" : "amount",  "bSortable": true},
                        { "sName" : "status_code",  "bSortable": true},
                        { "sName" : "remarks",  "bSortable": true}
                    ]
                });
            }); // end function

            function reassignDatagridEventAttr() {
            }
        </script>
        <div class="table-header">
            <?php echo __('MG Withdrawal Status') ?>
        </div>
        <div class="table-responsive">
        <table class="table table-striped table-bordered table-hover" id="datagrid" border="0" width="100%">
            <thead>
            <tr>
                <th></th>
                <th><?php echo __('Date') ?></th>
                <th><?php echo __('Withdrawal') ?></th>
                <th><?php echo __('Sub Total') ?></th>
                <th><?php echo __('Status') ?></th>
                <th><?php echo __('Remarks') ?></th>
            </tr>
            </thead>
        </table>
        </div>
    </div>
</div>

<div class="vspace-sm"></div>

<!-- /span -->
</div>
<!-- /row -->

<div class="hr hr32 hr-dotted"></div>

<!-- /row -->

<!-- PAGE CONTENT ENDS -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div><!-- /.page-content -->